package com.tensquare.article.dao;

import com.tensquare.article.pojo.Article;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Author:zimmor
 * @Date: 2021/3/1 22:06
 * @Description 文章数据接口
 * @version: 1.0.0
 */

public interface ArticleDao extends JpaRepository<Article, String>, JpaSpecificationExecutor {
    /**
     * 审核文章
     * @param articleId
     */
    //增删改，除了查询都需要有这个注释才能成功
    @Modifying
    @Query(value = "UPDATE tb_article SET state='1' WHERE id=?", nativeQuery = true)
    void updateStateById(String articleId);

    /**
     * 点赞
     * @param articleId
     */
    @Modifying
    @Query(value = "UPDATE tb_article SET thumbup=thumbup+1 WHERE id=?", nativeQuery = true)
    void updateThumbById(String articleId);
}
